class BasePlayer(object):
    '''
    Base class so I don't have to repeat bookkeeping stuff.
    '''
    
    def __repr__(self):
        try:
            return self.name
        except AttributeError:
            return NotImplemented
    
    def hunt_choices(*args, **kwargs):
        raise NotImplementedError("You must define a strategy!")
        
    def hunt_outcomes(*args, **kwargs):
        pass
        
    def round_end(*args, **kwargs):
        pass


class Player(BasePlayer):
    #global variables region
    number_of_hunters=0
    we_were_rewarded=False
    #end of global variables region
    def hunt_choices(
                    self,
                    round_number,
                    current_food,
                    current_reputation,
                    m,
                    player_reputations,
                    ):
        if round_number==1: #return hunt for all if it's the first round
            return ['h']*len(player_reputations)
        #import the global variables
        global number_of_hunters
        global we_were_rewarded
        #check if number of hunters of the last round is more than or equal m
        more_than_m=bool(number_of_hunters >= m )
        '''
        leave some food equal the amount required to hunt all players in the next round
        if number of hunters is more than m or we were rewarded so no worries about enlarging max hunt value
        '''
        if more_than_m or we_were_rewarded:
            max_hunt=max(len(player_reputations)-1,0)
        else:
            max_hunt=max((current_food/6)-(len(player_reputations)-1),0)
        #return slack for all players if max_hunt is negative
        if max_hunt==0:
            return ['s']*len(player_reputations)
        #creat an array if the pervious conditions were false
        players_array=[]
        #Apply the strategy
        current_hunts=0 
        for x in range(len(player_reputations)):
            if current_hunts <= max_hunt: #Apply max hunt strategy
                if x > 0.5 or (x == 0.5 and more_than_m):
                    #if the times of hunts made by the player is higher than his slacks or equals if number of hunters is greater than m
                    players_array+=['h'] #make a hunt for that player since he hunts alot
                    current_hunts+=1 #add one for the times we made a hunt
                else :
                    players_array+=['s'] #Slack if the player is often a slacker
            else:
                players_array+=['s'] #our food is not enough accourding to max hunt strategy
        return players_array #the result
        
    def hunt_outcomes(self, food_earnings):
        pass #nothing
        
    def round_end(self, award, m, number_hunters):
        '''
        get the number of huners
        determine if we were rewarded or not
        '''
        global number_of_hunters
        global we_were_rewarded
        number_of_hunters=number_hunters
        we_were_rewarded=bool(award!=0)
        
        
